package com.seckill.enums;

import java.util.Objects;

public enum ResultEnum {

    //通用异常
    SUCCESS(200, "成功"),
    SERVER_ERROR(500,"服务器出错"),

    //登陆异常
    IS_NULL(100100,"LoginVo [ userName ] 不可为空"),
    INVALID_LENGTH(100101,"LoginVo [ password ] 不可为空"),
    INVALID_PHONE(100201, "[ 请输入正确得手机号 ]");

    private int code;
    private String msg;

    private ResultEnum(int code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }



    public static ResultEnum match(String msg, ResultEnum defaultEnum){
        ResultEnum[] resultEnums = ResultEnum.values();
        for(ResultEnum resultEnum : resultEnums){
            if (Objects.equals(resultEnum.getMsg(), msg)) {
                return resultEnum;
            }
        }
        return defaultEnum;
    }

    public static void main(String[] args) {
        ResultEnum.IS_NULL.getCode();
    }


}
